/*
 * =============================================================================
 * Copyright© by Benjamin Sempere,
 * All rights reserved.
 * =============================================================================
 * Author  : Benjamin Sempere
 * E-mail  : benjamin@sempere.org
 * Homepage: www.sempere.org
 * =============================================================================
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.sempere.gwt.toolbox.remoting.client.rpc.controller;

import org.sempere.gwt.toolbox.core.client.controller.ApplicationController;
import org.sempere.gwt.toolbox.remoting.client.dto.ApplicationStartDTO;
import org.sempere.gwt.toolbox.remoting.client.rpc.callback.ApplicationStartedCallback;
import org.sempere.gwt.toolbox.remoting.client.rpc.service.lifecycle.LifeCycleServiceAsync;

public abstract class RPCApplicationController<T extends ApplicationStartDTO> extends ApplicationController {

	private ApplicationStartedCallback<T> callback;

	/**
	 * Default class constructor
	 * 
	 * @param callback
	 */
	public RPCApplicationController(ApplicationStartedCallback<T> callback) {
		this.callback = callback;
	}

	/**
	 * Return the life cycle service of the application
	 * 
	 * @return LifeCycleServiceAsync<T>
	 */
	public abstract LifeCycleServiceAsync<T> getLifeCycleService();

	@Override
	public final void startApplication() {
		this.getLifeCycleService().start(this.callback);
	}
}